nginx配置thinkPHP
简介:
首先,thinkPHP框架默认情况下可以解析的url路由是:http://xx.com/index.php?s= 这个样子的
所以,配置里就是将访问的网址‘/’后面的东西解析成上述的模样,s=后面的东西就是我们要加的路由如:
http://xx.com/home/index/index
解析为
http://xx.com/index.php?s=home/index/index
配置如下
server {
listen 80 default_server; #设置监听内容,以及默认服务器
server_name www.zhangyaze.com; #设置域名
index index.php index.html; #设置默认访问的文件
root /home/wwwroot/目录/public; #设置根目录
include enable-php.conf; #引入php解析的conf文件,有的版本好像默认引入不用写
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / { #解析内容,将访问路径根据上述规则进行更换
index index.php;
# !!!url重写!!!
if (!-e $request_filename) {
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
}
踩坑记录之open_basedir()报错
踩坑过程:
配置完之后,打开网站,白屏,打开后台发现500报错,但是并没有显示信息。
于是我去找到php.ini
lnmp安装的默认位置在:/usr/local/php/etc/里面
修改“display_errors = Off”将改为“On”将报错信息打开,
提示报错,是open_basedir()的问题,说明
我设置的目录只允许访问public下的,而其他的东西加载不进来
那还有个屁用
所以,经过我的查找,在nginx目录下用以下命令,就找到了个东西
grep -rn open_basedir ./在fastcgi.conf文件里面有一行
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/
反正约莫意思就是我设置的根目录下才是我的权限目录,所以,我打开加了个../,如下:
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/../:/tmp/:/proc/
重启nginx,万事大吉。
第一篇博客就留在这个thinkphp的身上吧。
封面图片封底:


These sites are my main sites of motivation. They've become my main sources of knowledge.
It's a great site that is informative and useful. If you've written this article and then praised yourself for your effort, I'd like to show my appreciation.

I'm sure that you'll be happy with the effort and time you've put into it. Your site is simple to browse. The most important information is readily available on your website.
This is an important reference source for information. I appreciate your participation! I required similar details to run my business. This site is a fantastic source.
The site is full of information. The information is invaluable, and I'm certain to recommend your site to my friends and acquaintances.
This website is helpful. I have saved it and am hoping to use it sooner or later. It's a great resource that should be made accessible. Thanks!
Thanks for reading this amazing piece. It was a great reading experience. Your blog is an incredible source of information regarding the current situation.
This is an excellent tip. It's best to talk about the subject in a short period. They're incredible. They're amazing! Amazing collection.



The authors applied their algorithm on 50 patients undergoing routine coronary calcium assessment by CT. viagra brand name generic drug is there a generic viagra on the market